package com.rongxing.entity;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import io.vertx.codegen.annotations.DataObject;
import io.vertx.core.json.JsonObject;
import lombok.Data;

import java.util.Date;

/**
 * @author Xu Haidong
 * @date 2018/8/2
 */
@Data
@Table("t_user")
@DataObject(generateConverter = true)
public class User {

    @Id(keyType = KeyType.None)
    private Long test_id;
    /**
     * 名称
     */
    private String name;
    /**
     * 年龄
     */
    private Integer age;
    /**
     * 这里故意演示注解可无
     */
    //@TableLogic
    private Integer testType;

    /**
     * 测试插入填充
     */
    @Column(onInsertValue = "now()",onUpdateValue = "now()")
    //@TableField(fill = FieldFill.INSERT)
    private Date testDate;

    private Long role;

    private String phone;

    public User() {
    }

    public User(JsonObject jsonObject) {
        UserConverter.fromJson(jsonObject, this);
    }

    public JsonObject toJson() {
        JsonObject json = new JsonObject();
        UserConverter.toJson(this, json);
        return json;
    }
}
